package javatunes;

public class mhit implements Comparable<mhit> {
	
	int tracknumber;
	String title;
	String artist;
	String album;
	String genre;
	String location;
	
	/**   indexes are 1 less than type number
	 * 	0	Title
	 *	1	Location (filename)
	 *	2	Album
	 *	3	Artist
	 *	4	Genre
	 *	5	Filetype
	 *	6	EQ Setting
	 *	7	Comment
	 *	8	Category
	 *	11	Composer
	 *	12	Grouping
	 */
	public mhit (String[] strs,int tracknumber) {
		title=strs[0]==null?"":strs[0];
		location=strs[1]==null?"":strs[1];
		album=strs[2]==null?"":strs[2];
		artist=strs[3]==null?"":strs[3];
		genre=strs[4]==null?"":strs[4];
		this.tracknumber=tracknumber;
	}
	
	public String toString () {
		return artist+" - "+album+" - "+tracknumber+" - "+title/*+" - "+location*/;
	}
	
	public String getFileName (String basedir) {
		if (location.length()==0) return "";
		basedir=basedir.replace('/','\\');
		if (!basedir.endsWith("\\")) basedir+="\\";
		return basedir+location.trim().substring(1).replace(':','\\');
	}
	
	public String getExtension () {
		if (location.length()<4) return "";
		return location.substring(location.length()-3,location.length());
	}
	
	public int compareTo(mhit o1) {
		return toString().compareTo(o1.toString());
	}
	
}
